﻿using AutoMapper;
using EWC.HIS.Application.Contracts.AppointmentRegistrationService.Dtos;
using EWC.HIS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EWC.HIS.Application
{
    public class MappingProfile : Profile
    {
        public MappingProfile()
        {
            #region AppointmentRegistration
            CreateMap<CreateAppointmentRegistrationDto, AppointmentRegistration>();
            CreateMap<AppointmentRegistrationDto, AppointmentRegistration>();
            CreateMap<AppointmentRegistration, AppointmentRegistrationDto>();
            CreateMap<UpdateAppointmentRegistrationDto, AppointmentRegistration>();
            CreateMap<AppointmentRegistration, UpdateAppointmentRegistrationDto>();
            CreateMap<AppointmentRegistration, AppointmentRegistrationListDto>();
            CreateMap<AppointmentRegistrationListDto, AppointmentRegistration>();
            CreateMap<Tuple<int, IEnumerable<AppointmentRegistration>>, Tuple<int, IEnumerable<AppointmentRegistrationListDto>>>()
                        .ConvertUsing((sourceTuple, targetTuple, context) =>
                        {
                            // 将源Tuple的成员映射到目标Tuple的成员
                            var targetItem2 = context.Mapper.Map<IEnumerable<AppointmentRegistrationListDto>>(sourceTuple.Item2);
                            return new Tuple<int, IEnumerable<AppointmentRegistrationListDto>>(sourceTuple.Item1, targetItem2);
                        });
            #endregion
            //.ForMember(dest => dest.AppointmentTime, opt => opt.MapFrom(src => src.AppointmentTime));
        }
    }
}
